/**
 * Created by GUO on 2017/5/20.
 * @flow
 */

import React from 'react';
import {
    Text,
    StyleSheet,
    PixelRatio,
    TouchableOpacity,
} from 'react-native';

export default class WeeklyItem extends React.PureComponent{

    props: {
        data: Object,
    }

    render(){

        let {title,time} = this.props.data;

        return (
            <TouchableOpacity activeOpacity={0.5} style = {styles.item}>
                <Text style={styles.itemName}>{title}</Text>
                <Text style={styles.itemDate}>{this._timeFormat(time)}</Text>
            </TouchableOpacity>
        );
    }

    _timeFormat(time: number): string{
        let date = new Date(time);
        return `${date.getMonth()+1}月${date.getDate()}日`;
    }
}

export const ITEM_HEIGHT = 48;
const styles = StyleSheet.create({
    item:{
        height:ITEM_HEIGHT,
        backgroundColor:'white',
        flexDirection: 'row',
        justifyContent:'flex-start',
        alignItems:'center',
        paddingHorizontal:10,
        borderBottomWidth: 1/PixelRatio.get(),
        borderColor:'#eaeaea'
    },
    itemName:{
        fontSize:18,
        color:'black',
        flex:1,
    },
    itemDate:{
        fontSize:14,
        color:'rgba(0,0,0,0.54)',
    },
});